package com.jerry.chinesechess.model;

import com.jerry.chinesechess.enums.PieceType;
import com.jerry.chinesechess.enums.Player;
import lombok.Data;

import static com.jerry.chinesechess.ChinesechessApplication.*;

@Data
public class Piece {
    //半径
    double w = (chessW + 1) * 2;
    private PieceType type;
    private Player player;
    private Position position;
    private boolean selected;
    
    public Piece(PieceType type, Player player, Position position) {
        this.type = type;
        this.player = player;
        this.position = position;
    }
    
    public String getDisplayName() {
        return player == Player.RED ? type.getRedName() : type.getBlackName();
    }
    
    public void moveTo(Position newPosition) {
        this.position = newPosition;
    }

    public Double getX(){
        return girdW/2 - chessW + girdW*position.getCol();
    }
    public Double getY(){
        return girdH/2 - chessW  + girdH*position.getRow();
    }
    public Double getX( int x){
        return girdW/2 - chessW + girdW*x;
    }
    public Double getY(int y){
        return girdH/2 - chessW  + girdH*y;
    }


}